<%@ include file="/taglibs.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<head>
<title>北京邮电大学学生党员在线学习中心</title>
<link href="${ctx}/css/pagination.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
	var xmlHttp;

	function changeSecond(value) {
		if (value != -1) {
			var uri = "AdminAction_getChildrenPaByParentId?parentId="
					+ escape(value);
			if (window.XMLHttpRequest) {
				xmlHttp = new XMLHttpRequest();
			} else {
				try {
					xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
						alert("不能创建XMLHttpRequest对象!!!");
						return;
					}
				}
			}
			xmlHttp.open("post", uri, true);
			xmlHttp.onreadystatechange = handleResponse;
			xmlHttp.send(null);
		} else {
			clearElement1("secondPa");
		}
	}

	function handleResponse() {
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				updateSelect("secondPa");
				var idList = xmlHttp.responseXML.getElementsByTagName("id");
				if (idList.length < 1) {
					clearElement1("secondPa");
				} else {
					;
				}
			}
		}
	}

	//根据返回的结果更新党支部信息
	function updateSelect(id) {
		var selectList = document.getElementById(id);
		var idList = xmlHttp.responseXML.getElementsByTagName("id");
		var nameList = xmlHttp.responseXML.getElementsByTagName("branchName");
		if (idList.length > 0) {
			document.getElementById(id).style.display = "inline";
			clearElement(id);
			selectList.options.add(new Option('请选择党支部', '-1'));
			for ( var i = 0; i < idList.length; i++) {
				selectList.options.add(new Option(
						nameList[i].firstChild.nodeValue,
						idList[i].firstChild.nodeValue));
			}
		} else {
			document.getElementById(id).style.display = "none";
		}

	}

	//清除元素
	function clearElement(id) {
		document.getElementById(id).length = 0;
	}

	//当只有一级或者两级党组织时，需要清理遗留的其他党组织信息
	function clearElement1(id) {
		var selectList = document.getElementById(id);
		clearElement(id);
		selectList.options.add(new Option('请选择党支部', '-1'));
		document.getElementById(id).style.display = "none";
	}
</script>





<script type="text/javascript">
	function delAlert(adminNO, highLevelQuery, queryContent, firstPaHidden,
			secondPaHidden, pageNow) {
		if (confirm('确实要删除吗?')) {
			window.location.href = "${ctx }/AdminAction_deleteAdmin?adminNO="
					+ adminNO + "&highLevelQuery=" + highLevelQuery
					+ "&queryContent=" + encodeURI(queryContent)
					+ "&firstPaHidden=" + firstPaHidden + "&secondPaHidden="
					+ secondPaHidden + "&pageNow=" + pageNow;

		}
		return false;
	}

	function exportExcel(highLevelQuery, queryContent, firstPa, secondPa) {

		/* alert("highLevelQuery:"+highLevelQuery);
		alert("queryContent:"+queryContent);
		alert("firstPa:"+firstPa);
		alert("secondPa:"+secondPa); */
		window.location.href = "${ctx}/AdminAction_exportAdmins?highLevelQuery="
				+ highLevelQuery
				+ "&queryContent="
				+ encodeURI(queryContent)
				+ "&firstPa=" + firstPa + "&secondPa=" + secondPa;
	}
</script>




</head>
<div id="nav_bar">
	<img id="nav_bar_left" src="../../../styles/nav_bar_left.png" alt="" />
	<div id="welcome_label">
		欢迎您，&nbsp;
		<s:property value="#session.session_user.adminName" />
		!
	</div>
	<img id="nav_bar_seperator" src="../../../styles/nav_bar_seperator.png"
		alt="" />
	<div id="nav_location">
		<img id="nav_bar_point" src="../../../styles/nav_bar_point.png" alt="" />
		<div id="nav_cur_location">
			当前位置：&nbsp;<a href="${ctx}/AdminAction_manageUser">用户管理</a>&nbsp;&nbsp;>&nbsp;&nbsp;<span
				style="color: black;">管理员信息维护</span>
		</div>
	</div>
	<img style="float: right; width: 5px;"
		src="../../../styles/nav_bar_right.png" alt="" /> <a id="nav_logout"
		href="${ctx}/logoutAction_adminLogout">[安全退出]</a>
</div>
<div style="clear: both; height: 5px;">&nbsp;</div>

<div style="min-height: 450px;">
	<div id="side_menu" style="min-height: 710px;">
		<div id="side_menu_title">
			<img src="../../../styles/side_menu_title_img.png" alt="" /> <span>用户管理</span>
		</div>
		<div id="side_menu_title_bottom">&nbsp;</div>
		<div class="side_sub_menu">
			<div class="side_menu_point">&nbsp;</div>
			<a href="AdminAction_memberList">成员信息维护</a>
		</div>
		<div class="side_menu_seperator">&nbsp;</div>
		<div class="side_sub_menu">
			<div class="side_menu_point">&nbsp;</div>
			<a href="AdminAction_addStudent">新增学生用户</a>
		</div>
		<div class="side_menu_seperator">&nbsp;</div>
		<div class="side_sub_menu">
			<div class="side_menu_point">&nbsp;</div>
			<a href="AdminAction_resetUserPassword">用户密码重置</a>
		</div>
		<div class="side_menu_seperator">&nbsp;</div>
		<s:if test="#session.level == 2 || #session.level == 3">
			<div class="side_sub_menu">
				<div class="side_menu_point">&nbsp;</div>
				<a href="AdminAction_addAdministrator">新增管理员用户</a>
			</div>
			<div class="side_menu_seperator">&nbsp;</div>
			<div class="side_sub_menu_focus">
				<div class="side_menu_point">&nbsp;</div>
				<a href="AdminAction_adminList">管理员信息维护</a>
			</div>
		</s:if>
	</div>

	<div id="main_content">
		<div id="main_content_title">
			<img src="../../../styles/content_title_img.png" alt="" /> <span>管理员信息维护</span>
		</div>
		<div class="main_content_title_bottom">&nbsp;</div>

		<!-- 查询条件 -->
		<s:form action="AdminAction_adminList" name="form1" id="form1"
			method="post" theme="simple">
			<table cellspacing="8px" cellpadding="0" style="border:0px; background-color:#ffede1; width:98%;">
					<tr>
						<td style="width:130px; text-align:right;">高级搜索：</td>
						<td style="width:200px; text-align:left;">
							<s:select list="#{1:'姓名', 2:'学号', 3:'身份证'}" listKey="key"
							  listValue="value" value="#request.highLevelQuery" name="highLevelQuery"
							  headerKey="-1" headerValue="请选择查询条件"></s:select>
						
						</td>
						<td style="width:100px; text-align:right;">请输入查询内容：</td>
						<td style="width:200px;"><input type="text" name="queryContent" value="${queryContent }">
						</td>
						<td style="valign:middle;" rowspan="2">
							<input type="submit" name="button" id="button" value="查询" class="input-button"  style="height:30px; width:60px;"/>
						</td>
					</tr>
					<tr>
						<td style="text-align:right;">所属党组织：</td>
						<td style="text-align:left;" colspan="3">
							<s:select id="firstPa" list="firstPaList" listKey="id" listValue="branchName" name="firstPa" headerKey="-1" headerValue="请选择党委"    onchange="changeSecond(this.value);" value="#request.firstPa" style="width:40%;"/>
							
								<s:select id="secondPa" list="secondPaList" listKey="id" listValue="branchName" name="secondPa" headerKey="-1" headerValue="请选择支部"  value="#request.secondPa" style="width:50%;"/>
						</td>
						<td></td>
					</tr>
		
				</table>
			<br />
			<div align="right">
				<input type="button" class="input-button" name="export" value="导出查询结果" 
					onClick="javascript:exportExcel('<s:property value="highLevelQuery"/>','<s:property value="queryContent"/>','<s:property value="firstPa"/>','<s:property value="secondPa"/>');" />
				&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
			<div style="clear: both; height: 5px;"></div>
			<table id="theListTable" class="list-table" cellspacing="0"
				cellpadding="0">
				<!-- 表头-->

				<TR>
					<TH>姓名</TH>
					<TH>工号</TH>
					<TH>身份证号</TH>
					<TH style="width: 360px;">管理组织</TH>
					<TH>相关操作</TH>
				</TR>


				<!--显示数据列表-->
				<s:iterator value="currentAdminList" status="record" id="record">
					<TR>
						<TD><s:property value="adminName" /></TD>
						<TD><s:property value="adminNo" /></TD>
						<TD><s:property value="adminIdentity" /></TD>
						<TD style="width: 360px;"><s:property
								value="branchIdToNameMap.get(adminManageBranchId)" /></TD>
						<TD><a
							href="AdminAction_viewAdminInfo?adminNO=<s:property value="adminNo"/>">查看</a>&nbsp;&nbsp;&nbsp;&nbsp;

							<a
							href="AdminAction_modifyAdminInfo?adminNO=<s:property value="adminNo"/>&highLevelQuery=<s:property value="#request.highLevelQuery"/>&queryContent=<s:property value="#request.queryContent"/>&firstPaHidden=<s:property value="#request.firstPa"/>&secondPaHidden=<s:property value="#request.secondPa"/>&pageNow=<s:property value="#request.pageNow"/>">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="#"
							onclick="delAlert('<s:property value="adminNo"/>','<s:property value="#request.highLevelQuery"/>','<s:property value="#request.queryContent"/>','<s:property value="#request.firstPa"/>','<s:property value="#request.secondPa"/>','<s:property value="#request.pageNow"/>');">删除</a>
						</TD>
					</TR>
				</s:iterator>
			</table>
		</s:form>


		<div style="clear: both; height: 10px;"></div>

		<div style="margin-left: 0; text-align: center;">
			<s:property value="paginationCode" escape="false" />
		</div>

	</div>
	<div style="clear: both">&nbsp;</div>
</div>



